#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# libpmempool_bttdev/TEST8 -- test for checking btt
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type any

setup

POOL=$DIR/file.pool
LOG=out${UNITTEST_NUM}.log
LOG_TEMP=out${UNITTEST_NUM}_part.log
rm -f $LOG && touch $LOG
rm -f $LOG_TEMP && touch $LOG_TEMP
EXE=../libpmempool_api/libpmempool_test

expect_normal_exit $BTTCREATE $POOL >> $LOG

declare -A btt_info_dic_err=(["sig"]="ERROR" ["uuid"]="01-02"
	["flags"]="7" ["major"]="7" ["minor"]="7"
	["nfree"]="7" ["infosize"]="7" ["nextoff"]="7"
	["dataoff"]="7" ["infooff"]="7" ["unused"]="7"
	["parent_uuid"]="03-04" ["mapoff"]="7" ["flogoff"]="7")

for field in flags unused major sig nextoff infosize infooff dataoff nfree mapoff uuid parent_uuid flogoff minor
do
	spcmd="bttdevice.arena(0).btt_info.$field=${btt_info_dic_err["$field"]}"

	rm -f $POOL

	expect_normal_exit $BTTCREATE $POOL
	$PMEMSPOIL -v $POOL $spcmd >> $LOG_TEMP

	expect_normal_exit $EXE$EXESUFFIX -r 1 -t btt $POOL
	cat $LOG >> $LOG_TEMP

	check_file $POOL
done

mv $LOG_TEMP $LOG

check

pass
